<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: brand_info.php 140 2013-09-22 07:44:23Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 140 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:44:23 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

$box_smarty = new smarty;

if(isset($_GET['brand']))
	$get_brand = $_GET['brand'];
elseif(isset($_GET['filter_id']))
	$get_brand = $_GET['filter_id'];

if($product->isProduct()) {
	$brand = $db->db_query("SELECT
								b.brand_id,
								b.brand_name,
								b.brand_image,
								bi.brand_url
							FROM
								".TABLE_BRAND." b
									LEFT JOIN ".TABLE_BRAND_INFO." bi
									ON (b.brand_id = bi.brand_id AND bi.languages_id = '".(int)$_SESSION['languages_id']."'),
								".TABLE_PRODUCTS." p
							WHERE
								p.products_id = '".$product->data['products_id']."'
							AND
								p.brand_id = b.brand_id");
								
} elseif(isset($get_brand) && !empty($get_brand)) {
	$brand = $db->db_query("SELECT
								b.brand_id,
								b.brand_name,
								b.brand_image,
								bi.brand_url,
								bi.brand_description
							FROM
								".TABLE_BRAND." b,
								".TABLE_BRAND_INFO." bi
							WHERE
								b.brand_id = '".$get_brand."'
							AND 
								bi.brand_id = b.brand_id 
							AND 
								bi.languages_id = '".(int)$_SESSION['languages_id']."'");
}

if($brand->_numOfRows) {
	if (!empty($brand->fields['brand_image']))
		$image = DIR_WS_IMAGES.$brand->fields['brand_image'];
		
	$box_smarty->assign('IMAGE', $image);
	$box_smarty->assign('IMAGE_DIMENSION', get_img_size($image));

	if($brand->fields['brand_url']!='')
		$box_smarty->assign('NAME_URL', '<a href="'.href_link(FILENAME_REDIRECT, 'action=brand&'.brand_link($brand->fields['brand_id'],$brand->fields['brand_name'])).'">'.$brand->fields['brand_name'].'</a>');
	else
		$box_smarty->assign('NAME_URL', $brand->fields['brand_name']);
	
	if(!empty($brand->fields['brand_description']))
		$box_smarty->assign('MORE_INFOS', '');
	
	if($product->isProduct())
		$box_smarty->assign('LINK_MORE','<a href="'.href_link(FILENAME_DEFAULT, brand_link($brand->fields['brand_id'],$brand->fields['brand_name'])).'">'.BOX_BRAND_INFO_OTHER_PRODUCTS.'</a>');

	$box_smarty->assign('language', $_SESSION['language']);
	$box_smarty->assign('tpl_path','templates/'.CURRENT_TEMPLATE.'/');
	$box_smarty->assign('html_tpl_path', CURRENT_TEMPLATE.'/html');

	if(!CacheCheck()) {
		$box_smarty->caching = false;
		$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_brand_info.html');
	} else {
		$box_smarty->caching = true;
		$box_smarty->cache_lifetime=CACHE_LIFETIME;
		$box_smarty->cache_modified_check=CACHE_CHECK;
		$cache_id = $_SESSION['language'].$product->data['products_id'];
		$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_brand_info.html',$cache_id);
	}
}
?>